#define _CRT_SECURE_NO_WARNINGS 1
int com(const void* p1, const void* p2)
{
    return *(int*)p1 - *(int*)p2;
}

int heightChecker(int* heights, int heightsSize) {
    int count = 0;
    int* p = (int*)malloc(sizeof(int) * heightsSize);
    for (int i = 0; i < heightsSize; i++)
    {
        p[i] = heights[i];
    }
    qsort(heights, heightsSize, sizeof(heights[0]), com);
    for (int i = 0; i < heightsSize; i++)
    {
        if (heights[i] != p[i])
            count++;
    }
    return count;
}